<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>工作流示例</title>
    <script src="/js/workflow.js"></script>
    <style>
        /* 重置默认样式 */
        html, body {
            margin: 0;
            padding: 0;
            height: 100%;
            overflow: hidden;
        }
        
        .page-container {
            display: flex;
            height: 100%;
            overflow: hidden;
        }
        
        .business-content {
            flex: 1;
            padding: 20px;
            border-right: 1px solid #ebeef5;
            overflow: auto; /* 如果业务内容过长，只在内容区域显示滚动条 */
        }
        
        .workflow-sidebar {
            width: 300px;
            border-left: 1px solid #ebeef5;
            overflow: hidden; /* 确保侧边栏不会出现滚动条 */
        }
    </style>
</head>
<body>
<div class="page-container">
    <div class="business-content">
        <!-- 业务内容区域 -->
        <h2>请假申请</h2>
        <p>这里是业务表单内容...</p>
    </div>
    <div class="workflow-sidebar">
        <div id="workflowContainer"></div>
    </div>
</div>
<script>
    // 初始化工作流审核
    const workflowAudit = new WorkflowAudit({
        taskId: taskId,
        instanceId: instanceId,
        ctx: ctx,
        // 前置处理回调
        beforeSubmitCallback: async function (operation) {
            let amount = $("#amount").val();
            let maxAmount = [[${maxAmount}]];
            if (activityCode == '市人社局(复审)' && operation.value === 'APPROVED') {
                if (amount == null || amount == '') {
                    console.log("房票金额不能为空");
                    return false;
                }
                if (isNaN(amount)) {
                    console.log("房票金额必须为数字");
                    return false;
                } else {
                    if (parseFloat(amount) <= 0) {
                        console.log("房票金额必须大于0");
                        return false;
                    }
                    if (parseFloat(amount) > maxAmount){
                        console.log("房票金额不能超过" + maxAmount + "万元");
                        return false;
                    }
                }
                return new Promise((resolve) => {
                    const params = {
                        id: [[${roomTicketSubsidy.id}]],
                        amount: amount
                    };
                    layui.starter.post(ctx + "biz/room/ticket/subsidy/updateAmount", params, function (res) {
                        resolve(true);
                    });
                });
            }
            return true;
        }
    });
</script>
</body>
</html>